package research.ui.views.filters;

import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;

import research.entity.Entity;
import research.entity.EntityType;

public class EntityNameFilter extends ViewerFilter {
	private String txt;
	private EntityType type;

	public EntityNameFilter(String txt, EntityType type) {
		super();
		this.txt = txt;
		this.type = type;
	}

	public boolean select(Viewer viewer, Object parentElement,
			Object element) {
		if (element instanceof Entity) {
			Entity ent = (Entity) element;
			if (ent.getType().equals(type))
				return ent.toString().toLowerCase().indexOf(txt.toLowerCase()) >= 0;
		}
		return true;
	}

}